@echo off

@REM show some needed path
@REM echo curent disk:%~d0
@REM echo current path:%~dp0
@REM echo fullpath:%~f0
@REM echo short path:%~sdp0
@REM echo default path:%cd%

@REM set the scirpt file location
set batdir=%~dp0
@REM set the environment variable
set path=%path%
@REM set the current path(the pom file location of project)
set mydir=%cd%

cd %mydir%

@REM clean the target directory
if exist %mydir%\target\ ( 
echo "delete the target directory"
del/s/q target
rd/s/q target
@rem aa
)

@REM In current location execute: mvn clean archetype:create-from-project
call mvn clean archetype:create-from-project

@REM execute replace tools, replace some not complete
java -jar %batdir%archetype.jar %mydir%\target\generated-sources\archetype

@REM Install archetype template to Local Maven
cd target\generated-sources\archetype
call mvn clean install

@REM clean the target directory
cd ..\..\..\

if exist %mydir%\target\ ( 
echo "delete the target directory"
del/s/q target
rd/s/q target
@rem aa
)